home *** CD-ROM | disk | FTP | other *** search
- Path: news1.interserv.net!news
- From: <dvisage@interserv.com>
- Newsgroups: comp.lang.c++
- Subject: Get name of OCX container
- Date: 27 Mar 1996 12:09:43 GMT
- Organization: InterServ News Service
- Message-ID: <4jbb67$jrn@lal.interserv.net>
- NNTP-Posting-Host: ad16-083.compuserve.com
- Content-Type: text/plain
- Keywords: OCX
- Content-length: 767
- X-Newsreader: AIR Mosaic (32-bit) 4.00
-
-
- >I would like to obtain application specific data, primarily, what is
- >the name of the current application in which I (as an OCX Control) am
- >contained in?
- >
-
- If you can get a CWnd* to your OCX , you should be able to get the parent HWND. If you have the HWND of the parent
- window, you should be able to get the HINSTANCE. If you have the HINSTANCE, you should be able to get the name of
- the executable module :
-
- I think the calls you need are :
-
- CWnd* cw; // This is your OCX control
- HINSTANCE hInst;
- HWND hWnd;
- char name[255];
-
- hWnd = ::GetParent(cw->m_hwnd);
-
- hInst = (HINSTANCE) ::GetWindowLong(hWnd, GWL_HINSTANCE);
-
- ::GetModuleFileName(hinst, name, 255);
-
- There is probably a better way to do this using MFC.
-
-
-